/*
 * Person.java
 *
 * Creada el 27/01/2012, 01:20:10 PM
 *
 * Clase Java desarrollada por Edgar Ramos para 7i Software Factory el día 27/01/2012
 *
 * Para informacion sobre el uso de esta clase, asi como bugs, actualizaciones, o mejoras enviar un mail a
 * eramos@7i.com.mx
 *
 * Desarrollado por la célula de desarrollo de Zacatecas
 *
 */
package com.grupoquark.cic.model.person;

import java.io.Serializable;
import javax.persistence.*;
import org.apache.log4j.Logger;

/**
 * @author Edgar Ramos
 * @version 1.0
 * @author-mail eramos@7i.com.mx @date 27/01/2012
 */
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Person implements Serializable
{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    private String name;
    @Column(name = "first_surname")
    private String firstSurname; //This stands for father's surename.
    @Column(name = "second_surname")
    private String secondSurname; //This stands for mother's maiden name.
    //Other variables and constants
    private static final transient Logger LOG = Logger.getLogger(Person.class);

    protected Person()
    {

        if (LOG.isTraceEnabled())
        {
            LOG.trace("Empty Person created");
        }
    }

    public Person(String name, String firstSurname)
    {

        this.name = name;
        this.firstSurname = firstSurname;

        if (LOG.isTraceEnabled())
        {
            LOG.trace("Person Created: " + name + firstSurname);
        }
    }

    public Person(String name, String firstSurname, String secondSurname)
    {

        this.name = name;
        this.firstSurname = firstSurname;
        this.secondSurname = secondSurname;

        if (LOG.isTraceEnabled())
        {
            LOG.trace("Person Created: " + name + firstSurname + secondSurname);
        }
    }

    public String getFirstSurname()
    {
        return firstSurname;
    }

    public void setFirstSurname(String firstSurname)
    {
        this.firstSurname = firstSurname;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getSecondSurname()
    {
        return secondSurname;
    }

    public void setSecondSurname(String secondSurname)
    {
        this.secondSurname = secondSurname;
    }

    public long getId()
    {
        return id;
    }

    protected void setId(long id)
    {
        this.id = id;
    }

    @Override
    public String toString()
    {
        return "Person{" + "id=" + id + ", name=" + name + ", firstSurname=" + firstSurname + ", secondSurname=" + secondSurname + '}';
    }

    @Override
    public boolean equals(Object obj)
    {
        if (obj == null)
        {
            return false;
        }
        if (getClass() != obj.getClass())
        {
            return false;
        }
        final Person other = (Person) obj;
        if (this.id != other.id)
        {
            return false;
        }
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name))
        {
            return false;
        }
        if ((this.firstSurname == null) ? (other.firstSurname != null) : !this.firstSurname.equals(other.firstSurname))
        {
            return false;
        }
        if ((this.secondSurname == null) ? (other.secondSurname != null) : !this.secondSurname.equals(other.secondSurname))
        {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode()
    {
        int hash = 3;
        hash = 97 * hash + (int) (this.id ^ (this.id >>> 32));
        hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 97 * hash + (this.firstSurname != null ? this.firstSurname.hashCode() : 0);
        hash = 97 * hash + (this.secondSurname != null ? this.secondSurname.hashCode() : 0);
        return hash;
    }
}
